#include <iostream>
using namespace std;

bool perfect_num(int n)
{
    int j = 0;
    int sum = 0;
    for (j = 1; j < n; j++)
    {
        if (n % j == 0)
            sum += j;
    }
    return sum == n;
}

int main()
{
    int n = 0;
    cin >> n;
    int i = 0;
    for (i = 2; i <= n; i++)
    {
        if (perfect_num(i))
        {
            cout << i << endl;
        }
    }
    return 0;
}
